package com.cml.df.datasource.confmgr.infrastructure.dao;

import com.cml.df.datasource.confmgr.infrastructure.dao.mapper.DatasourceAttrMapper;
import com.cml.df.datasource.confmgr.infrastructure.dao.mapper.DatasourceMapper;
import com.cml.df.datasource.confmgr.domain.entity.Datasource;
import com.cml.df.datasource.confmgr.domain.entity.DatasourceAttr;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 姓名：陈茂林
 * 时间：2024/11/19
 * 描述：
 */
@Component
public class DatasourceDao {
    @Autowired
    private DatasourceMapper datasourceMapper;

    @Autowired
    private DatasourceAttrMapper datasourceAttrMapper;
    public void save(Datasource datasource){
        Integer datasourceId = datasourceMapper.insert(datasource);

        DatasourceAttr datasourceAttr =  datasource.getDatasourceAttr();
        datasourceAttr.setDatasourceId(datasourceId);

        datasourceAttrMapper.insert(datasourceAttr);
    }
}
